package fyp.spedmew;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class CreateJobGetLocationActionBarActivity extends ActionBarActivity {

    Bundle jobData = new Bundle();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_job_get_location);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        Intent in = getIntent();
        jobData = in.getExtras();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_create__shipment3, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void sendMessage(View view) {
        final Button btn = (Button) findViewById(R.id.nextLoc_btn);
        btn.setBackgroundColor(getResources().getColor(R.color.button_BG_OnPressed));

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                btn.setBackgroundColor(getResources().getColor(R.color.button_BG));
            }
        }, 300);

        EditText pick_upET = (EditText) findViewById(R.id.pickup_loc);
        EditText drop_offET = (EditText) findViewById(R.id.dropoff_loc);
        EditText recipient_noET = (EditText) findViewById(R.id.recipient_no);

        /* Intent Get_i = getIntent();
        String name = Get_i.getStringExtra(CreateJobAddPictureActionBarActivity.key_name);
        String descr = Get_i.getStringExtra(CreateJobAddPictureActionBarActivity.key_description);
        String dates = Get_i.getStringExtra(CreateJobAddPictureActionBarActivity.key_shipment_date);
        String price = Get_i.getStringExtra(CreateJobAddPictureActionBarActivity.key_price);
        String pic = "";
        String pick_up = pick_upET.getText().toString();
        String drop_off = drop_offET.getText().toString();
        String recipient_no = recipient_noET.getText().toString(); */

        Intent out = new Intent(this, CreateJobCustomInstructionActionBarActivity.class);
       // jobData.putString("pickupLoc", pick_upET.toString());
        jobData.putString("pickupLoc", pick_upET.getText().toString());
        jobData.putString("dropoffLoc", drop_offET.getText().toString());
        jobData.putString("recipientNo", recipient_noET.getText().toString());
        out.putExtras(jobData);

        /* i.putExtra(key_name, name);
        i.putExtra(key_description, descr);
        i.putExtra(key_shipment_date, dates);
        i.putExtra(key_price, price);
        i.putExtra(Key_pic, pic);
        i.putExtra(Key_dropOff, drop_off);
        i.putExtra(Key_pickup, pick_up);
        i.putExtra(Key_recipient_no, recipient_no); */

        startActivity(out);
    }
}
